home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Technology Seed / Jan. '98 ATS.toast / QuickTime™ 3.0b11 / QTPublicInterfaces / CIncludes / SpeechSynthesis.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-12  |  12.9 KB  |  395 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        SpeechSynthesis.h
  3.  
  4.      Contains:    Speech Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 3.0 Beta
  8.  
  9.      Copyright:    © 1989-1997 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __SPEECHSYNTHESIS__
  19. #define __SPEECHSYNTHESIS__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. #ifndef __FILES__
  28. #include <Files.h>
  29. #endif
  30.  
  31.  
  32.  
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42. #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52.  
  53.  
  54. enum {
  55.     kTextToSpeechSynthType        = FOUR_CHAR_CODE('ttsc'),
  56.     kTextToSpeechVoiceType        = FOUR_CHAR_CODE('ttvd'),
  57.     kTextToSpeechVoiceFileType    = FOUR_CHAR_CODE('ttvf'),
  58.     kTextToSpeechVoiceBundleType = FOUR_CHAR_CODE('ttvb')
  59. };
  60.  
  61.  
  62. enum {
  63.     kNoEndingProsody            = 1,
  64.     kNoSpeechInterrupt            = 2,
  65.     kPreflightThenPause            = 4
  66. };
  67.  
  68.  
  69. enum {
  70.     kImmediate                    = 0,
  71.     kEndOfWord                    = 1,
  72.     kEndOfSentence                = 2
  73. };
  74.  
  75.  
  76. /*------------------------------------------*/
  77. /* GetSpeechInfo & SetSpeechInfo selectors    */
  78. /*------------------------------------------*/
  79.  
  80. enum {
  81.     soStatus                    = FOUR_CHAR_CODE('stat'),
  82.     soErrors                    = FOUR_CHAR_CODE('erro'),
  83.     soInputMode                    = FOUR_CHAR_CODE('inpt'),
  84.     soCharacterMode                = FOUR_CHAR_CODE('char'),
  85.     soNumberMode                = FOUR_CHAR_CODE('nmbr'),
  86.     soRate                        = FOUR_CHAR_CODE('rate'),
  87.     soPitchBase                    = FOUR_CHAR_CODE('pbas'),
  88.     soPitchMod                    = FOUR_CHAR_CODE('pmod'),
  89.     soVolume                    = FOUR_CHAR_CODE('volm'),
  90.     soSynthType                    = FOUR_CHAR_CODE('vers'),
  91.     soRecentSync                = FOUR_CHAR_CODE('sync'),
  92.     soPhonemeSymbols            = FOUR_CHAR_CODE('phsy'),
  93.     soCurrentVoice                = FOUR_CHAR_CODE('cvox'),
  94.     soCommandDelimiter            = FOUR_CHAR_CODE('dlim'),
  95.     soReset                        = FOUR_CHAR_CODE('rset'),
  96.     soCurrentA5                    = FOUR_CHAR_CODE('myA5'),
  97.     soRefCon                    = FOUR_CHAR_CODE('refc'),
  98.     soTextDoneCallBack            = FOUR_CHAR_CODE('tdcb'),        /* use with SpeechTextDoneProcPtr*/
  99.     soSpeechDoneCallBack        = FOUR_CHAR_CODE('sdcb'),        /* use with SpeechDoneProcPtr*/
  100.     soSyncCallBack                = FOUR_CHAR_CODE('sycb'),        /* use with SpeechSyncProcPtr*/
  101.     soErrorCallBack                = FOUR_CHAR_CODE('ercb'),        /* use with SpeechErrorProcPtr*/
  102.     soPhonemeCallBack            = FOUR_CHAR_CODE('phcb'),        /* use with SpeechPhonemeProcPtr*/
  103.     soWordCallBack                = FOUR_CHAR_CODE('wdcb'),
  104.     soSynthExtension            = FOUR_CHAR_CODE('xtnd'),
  105.     soSoundOutput                = FOUR_CHAR_CODE('sndo')
  106. };
  107.  
  108.  
  109. /*------------------------------------------*/
  110. /* Speaking Mode Constants                     */
  111. /*------------------------------------------*/
  112.  
  113. enum {
  114.     modeText                    = FOUR_CHAR_CODE('TEXT'),        /* input mode constants                     */
  115.     modePhonemes                = FOUR_CHAR_CODE('PHON'),
  116.     modeNormal                    = FOUR_CHAR_CODE('NORM'),        /* character mode and number mode constants */
  117.     modeLiteral                    = FOUR_CHAR_CODE('LTRL')
  118. };
  119.  
  120.  
  121.  
  122. enum {
  123.     soVoiceDescription            = FOUR_CHAR_CODE('info'),
  124.     soVoiceFile                    = FOUR_CHAR_CODE('fref')
  125. };
  126.  
  127.  
  128.  
  129. struct SpeechChannelRecord {
  130.     long                             data[1];
  131. };
  132. typedef struct SpeechChannelRecord        SpeechChannelRecord;
  133.  
  134. typedef SpeechChannelRecord *            SpeechChannel;
  135.  
  136.  
  137. struct VoiceSpec {
  138.     OSType                             creator;
  139.     OSType                             id;
  140. };
  141. typedef struct VoiceSpec                VoiceSpec;
  142. typedef VoiceSpec *                        VoiceSpecPtr;
  143.  
  144.  
  145. enum {
  146.     kNeuter                        = 0,
  147.     kMale                        = 1,
  148.     kFemale                        = 2
  149. };
  150.  
  151.  
  152.  
  153.  
  154.  
  155. struct VoiceDescription {
  156.     long                             length;
  157.     VoiceSpec                         voice;
  158.     long                             version;
  159.     Str63                             name;
  160.     Str255                             comment;
  161.     short                             gender;
  162.     short                             age;
  163.     short                             script;
  164.     short                             language;
  165.     short                             region;
  166.     long                             reserved[4];
  167. };
  168. typedef struct VoiceDescription            VoiceDescription;
  169.  
  170.  
  171.  
  172. struct VoiceFileInfo {
  173.     FSSpec                             fileSpec;
  174.     short                             resID;
  175. };
  176. typedef struct VoiceFileInfo            VoiceFileInfo;
  177.  
  178. struct SpeechStatusInfo {
  179.     Boolean                         outputBusy;
  180.     Boolean                         outputPaused;
  181.     long                             inputBytesLeft;
  182.     short                             phonemeCode;
  183. };
  184. typedef struct SpeechStatusInfo            SpeechStatusInfo;
  185.  
  186.  
  187.  
  188. struct SpeechErrorInfo {
  189.     short                             count;
  190.     OSErr                             oldest;
  191.     long                             oldPos;
  192.     OSErr                             newest;
  193.     long                             newPos;
  194. };
  195. typedef struct SpeechErrorInfo            SpeechErrorInfo;
  196.  
  197.  
  198.  
  199. struct SpeechVersionInfo {
  200.     OSType                             synthType;
  201.     OSType                             synthSubType;
  202.     OSType                             synthManufacturer;
  203.     long                             synthFlags;
  204.     NumVersion                         synthVersion;
  205. };
  206. typedef struct SpeechVersionInfo        SpeechVersionInfo;
  207.  
  208.  
  209.  
  210. struct PhonemeInfo {
  211.     short                             opcode;
  212.     Str15                             phStr;
  213.     Str31                             exampleStr;
  214.     short                             hiliteStart;
  215.     short                             hiliteEnd;
  216. };
  217. typedef struct PhonemeInfo                PhonemeInfo;
  218.  
  219.  
  220. struct PhonemeDescriptor {
  221.     short                             phonemeCount;
  222.     PhonemeInfo                     thePhonemes[1];
  223. };
  224. typedef struct PhonemeDescriptor        PhonemeDescriptor;
  225.  
  226. struct SpeechXtndData {
  227.     OSType                             synthCreator;
  228.     Byte                             synthData[2];
  229. };
  230. typedef struct SpeechXtndData            SpeechXtndData;
  231.  
  232.  
  233. struct DelimiterInfo {
  234.     Byte                             startDelimiter[2];
  235.     Byte                             endDelimiter[2];
  236. };
  237. typedef struct DelimiterInfo            DelimiterInfo;
  238.  
  239. typedef CALLBACK_API( void , SpeechTextDoneProcPtr )(SpeechChannel chan, long refCon, const void **nextBuf, unsigned long *byteLen, long *controlFlags);
  240. typedef CALLBACK_API( void , SpeechDoneProcPtr )(SpeechChannel chan, long refCon);
  241. typedef CALLBACK_API( void , SpeechSyncProcPtr )(SpeechChannel chan, long refCon, OSType syncMessage);
  242. typedef CALLBACK_API( void , SpeechErrorProcPtr )(SpeechChannel chan, long refCon, OSErr theError, long bytePos);
  243. typedef CALLBACK_API( void , SpeechPhonemeProcPtr )(SpeechChannel chan, long refCon, short phonemeOpcode);
  244. typedef CALLBACK_API( void , SpeechWordProcPtr )(SpeechChannel chan, long refCon, unsigned long wordPos, unsigned short wordLen);
  245. typedef STACK_UPP_TYPE(SpeechTextDoneProcPtr)                     SpeechTextDoneUPP;
  246. typedef STACK_UPP_TYPE(SpeechDoneProcPtr)                         SpeechDoneUPP;
  247. typedef STACK_UPP_TYPE(SpeechSyncProcPtr)                         SpeechSyncUPP;
  248. typedef STACK_UPP_TYPE(SpeechErrorProcPtr)                         SpeechErrorUPP;
  249. typedef STACK_UPP_TYPE(SpeechPhonemeProcPtr)                     SpeechPhonemeUPP;
  250. typedef STACK_UPP_TYPE(SpeechWordProcPtr)                         SpeechWordUPP;
  251. enum { uppSpeechTextDoneProcInfo = 0x0000FFC0 };                 /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  252. enum { uppSpeechDoneProcInfo = 0x000003C0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes) */
  253. enum { uppSpeechSyncProcInfo = 0x00000FC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes) */
  254. enum { uppSpeechErrorProcInfo = 0x00003BC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 2_bytes, 4_bytes) */
  255. enum { uppSpeechPhonemeProcInfo = 0x00000BC0 };                 /* pascal no_return_value Func(4_bytes, 4_bytes, 2_bytes) */
  256. enum { uppSpeechWordProcInfo = 0x00002FC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes, 2_bytes) */
  257. #define NewSpeechTextDoneProc(userRoutine)                         (SpeechTextDoneUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechTextDoneProcInfo, GetCurrentArchitecture())
  258. #define NewSpeechDoneProc(userRoutine)                             (SpeechDoneUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechDoneProcInfo, GetCurrentArchitecture())
  259. #define NewSpeechSyncProc(userRoutine)                             (SpeechSyncUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechSyncProcInfo, GetCurrentArchitecture())
  260. #define NewSpeechErrorProc(userRoutine)                         (SpeechErrorUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechErrorProcInfo, GetCurrentArchitecture())
  261. #define NewSpeechPhonemeProc(userRoutine)                         (SpeechPhonemeUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechPhonemeProcInfo, GetCurrentArchitecture())
  262. #define NewSpeechWordProc(userRoutine)                             (SpeechWordUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechWordProcInfo, GetCurrentArchitecture())
  263. #define CallSpeechTextDoneProc(userRoutine, chan, refCon, nextBuf, byteLen, controlFlags)  CALL_FIVE_PARAMETER_UPP((userRoutine), uppSpeechTextDoneProcInfo, (chan), (refCon), (nextBuf), (byteLen), (controlFlags))
  264. #define CallSpeechDoneProc(userRoutine, chan, refCon)             CALL_TWO_PARAMETER_UPP((userRoutine), uppSpeechDoneProcInfo, (chan), (refCon))
  265. #define CallSpeechSyncProc(userRoutine, chan, refCon, syncMessage)  CALL_THREE_PARAMETER_UPP((userRoutine), uppSpeechSyncProcInfo, (chan), (refCon), (syncMessage))
  266. #define CallSpeechErrorProc(userRoutine, chan, refCon, theError, bytePos)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppSpeechErrorProcInfo, (chan), (refCon), (theError), (bytePos))
  267. #define CallSpeechPhonemeProc(userRoutine, chan, refCon, phonemeOpcode)  CALL_THREE_PARAMETER_UPP((userRoutine), uppSpeechPhonemeProcInfo, (chan), (refCon), (phonemeOpcode))
  268. #define CallSpeechWordProc(userRoutine, chan, refCon, wordPos, wordLen)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppSpeechWordProcInfo, (chan), (refCon), (wordPos), (wordLen))
  269. EXTERN_API( NumVersion )
  270. SpeechManagerVersion            (void)                                                        FOURWORDINLINE(0x203C, 0x0000, 0x000C, 0xA800);
  271.  
  272. EXTERN_API( OSErr )
  273. MakeVoiceSpec                    (OSType                 creator,
  274.                                  OSType                 id,
  275.                                  VoiceSpec *            voice)                                FOURWORDINLINE(0x203C, 0x0604, 0x000C, 0xA800);
  276.  
  277. EXTERN_API( OSErr )
  278. CountVoices                        (short *                numVoices)                            FOURWORDINLINE(0x203C, 0x0108, 0x000C, 0xA800);
  279.  
  280. EXTERN_API( OSErr )
  281. GetIndVoice                        (short                     index,
  282.                                  VoiceSpec *            voice)                                FOURWORDINLINE(0x203C, 0x030C, 0x000C, 0xA800);
  283.  
  284. EXTERN_API( OSErr )
  285. GetVoiceDescription                (const VoiceSpec *        voice,
  286.                                  VoiceDescription *        info,
  287.                                  long                     infoLength)                            FOURWORDINLINE(0x203C, 0x0610, 0x000C, 0xA800);
  288.  
  289. EXTERN_API( OSErr )
  290. GetVoiceInfo                    (const VoiceSpec *        voice,
  291.                                  OSType                 selector,
  292.                                  void *                    voiceInfo)                            FOURWORDINLINE(0x203C, 0x0614, 0x000C, 0xA800);
  293.  
  294. EXTERN_API( OSErr )
  295. NewSpeechChannel                (VoiceSpecPtr             voice,
  296.                                  SpeechChannel *        chan)                                FOURWORDINLINE(0x203C, 0x0418, 0x000C, 0xA800);
  297.  
  298. EXTERN_API( OSErr )
  299. DisposeSpeechChannel            (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x021C, 0x000C, 0xA800);
  300.  
  301. EXTERN_API( OSErr )
  302. SpeakString                        (ConstStr255Param         textToBeSpoken)                        FOURWORDINLINE(0x203C, 0x0220, 0x000C, 0xA800);
  303.  
  304. EXTERN_API( OSErr )
  305. SpeakText                        (SpeechChannel             chan,
  306.                                  const void *            textBuf,
  307.                                  unsigned long             textBytes)                            FOURWORDINLINE(0x203C, 0x0624, 0x000C, 0xA800);
  308.  
  309. EXTERN_API( OSErr )
  310. SpeakBuffer                        (SpeechChannel             chan,
  311.                                  const void *            textBuf,
  312.                                  unsigned long             textBytes,
  313.                                  long                     controlFlags)                        FOURWORDINLINE(0x203C, 0x0828, 0x000C, 0xA800);
  314.  
  315. EXTERN_API( OSErr )
  316. StopSpeech                        (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x022C, 0x000C, 0xA800);
  317.  
  318. EXTERN_API( OSErr )
  319. StopSpeechAt                    (SpeechChannel             chan,
  320.                                  long                     whereToStop)                        FOURWORDINLINE(0x203C, 0x0430, 0x000C, 0xA800);
  321.  
  322. EXTERN_API( OSErr )
  323. PauseSpeechAt                    (SpeechChannel             chan,
  324.                                  long                     whereToPause)                        FOURWORDINLINE(0x203C, 0x0434, 0x000C, 0xA800);
  325.  
  326. EXTERN_API( OSErr )
  327. ContinueSpeech                    (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x0238, 0x000C, 0xA800);
  328.  
  329. EXTERN_API( short )
  330. SpeechBusy                        (void)                                                        FOURWORDINLINE(0x203C, 0x003C, 0x000C, 0xA800);
  331.  
  332. EXTERN_API( short )
  333. SpeechBusySystemWide            (void)                                                        FOURWORDINLINE(0x203C, 0x0040, 0x000C, 0xA800);
  334.  
  335. EXTERN_API( OSErr )
  336. SetSpeechRate                    (SpeechChannel             chan,
  337.                                  Fixed                     rate)                                FOURWORDINLINE(0x203C, 0x0444, 0x000C, 0xA800);
  338.  
  339. EXTERN_API( OSErr )
  340. GetSpeechRate                    (SpeechChannel             chan,
  341.                                  Fixed *                rate)                                FOURWORDINLINE(0x203C, 0x0448, 0x000C, 0xA800);
  342.  
  343. EXTERN_API( OSErr )
  344. SetSpeechPitch                    (SpeechChannel             chan,
  345.                                  Fixed                     pitch)                                FOURWORDINLINE(0x203C, 0x044C, 0x000C, 0xA800);
  346.  
  347. EXTERN_API( OSErr )
  348. GetSpeechPitch                    (SpeechChannel             chan,
  349.                                  Fixed *                pitch)                                FOURWORDINLINE(0x203C, 0x0450, 0x000C, 0xA800);
  350.  
  351. EXTERN_API( OSErr )
  352. SetSpeechInfo                    (SpeechChannel             chan,
  353.                                  OSType                 selector,
  354.                                  const void *            speechInfo)                            FOURWORDINLINE(0x203C, 0x0654, 0x000C, 0xA800);
  355.  
  356. EXTERN_API( OSErr )
  357. GetSpeechInfo                    (SpeechChannel             chan,
  358.                                  OSType                 selector,
  359.                                  void *                    speechInfo)                            FOURWORDINLINE(0x203C, 0x0658, 0x000C, 0xA800);
  360.  
  361. EXTERN_API( OSErr )
  362. TextToPhonemes                    (SpeechChannel             chan,
  363.                                  const void *            textBuf,
  364.                                  unsigned long             textBytes,
  365.                                  Handle                 phonemeBuf,
  366.                                  long *                    phonemeBytes)                        FOURWORDINLINE(0x203C, 0x0A5C, 0x000C, 0xA800);
  367.  
  368. EXTERN_API( OSErr )
  369. UseDictionary                    (SpeechChannel             chan,
  370.                                  Handle                 dictionary)                            FOURWORDINLINE(0x203C, 0x0460, 0x000C, 0xA800);
  371.  
  372.  
  373.  
  374.  
  375. #if PRAGMA_STRUCT_ALIGN
  376.     #pragma options align=reset
  377. #elif PRAGMA_STRUCT_PACKPUSH
  378.     #pragma pack(pop)
  379. #elif PRAGMA_STRUCT_PACK
  380.     #pragma pack()
  381. #endif
  382.  
  383. #ifdef PRAGMA_IMPORT_OFF
  384. #pragma import off
  385. #elif PRAGMA_IMPORT
  386. #pragma import reset
  387. #endif
  388.  
  389. #ifdef __cplusplus
  390. }
  391. #endif
  392.  
  393. #endif /* __SPEECHSYNTHESIS__ */
  394.  
  395.